<template>
  <Submenu :name="`${parentName}`">
    <template slot="title">
      <Icon :type="parentItem.icon"/>
      <span>{{ showTitle(parentItem) }}</span>
      <span class="readNum" v-if="showMessage(parentItem)"></span>
    </template>
    <template v-for="item in children">
      <template v-if="item.children && item.children.length === 1">
        <side-menu-item v-if="showChildren(item)" :key="`menu-${item.name}`" :parent-item="item"></side-menu-item>
        <menu-item v-else :name="getNameOrHref(item, true)" :key="`menu-${item.children[0].name}`">
          <common-icon :type="item.children[0].icon || ''"/>
          <span>{{ showTitle(item.children[0]) }}</span>
          <span class="readNum" v-if="showMessage(item.children[0])"></span>
        </menu-item>
      </template>
      <template v-else>
        <side-menu-item v-if="showChildren(item)" :key="`menu-${item.name}`" :parent-item="item"></side-menu-item>
        <menu-item v-else :name="getNameOrHref(item)" :key="`menu-${item.name}`">
          <common-icon :type="item.icon || ''"/>
          <span>{{ showTitle(item) }}</span>
          <span class="readNum" v-if="showMessage(item)"></span>
        </menu-item>
      </template>
    </template>
  </Submenu>
</template>
<script>
import mixin from "./mixin";
import itemMixin from "./item-mixin";
export default {
  name: "SideMenuItem",
  mixins: [mixin, itemMixin]
};
</script>
<style lang="less" scoped>
.readNum {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 10px;
  background: #ff0000;
  margin-left: 20px;
}
</style>
